<?php 

/*********************************************************************
*  Class : Navigator
*  Function : 
*  Author :  joharijumali
*  Description: Class for Creating System Navigation
**********************************************************************/

class Navigator{

    /**
     * sidebar function
     * Create sidebar
     * @return string
     * @author joharijumali
     **/

  public static function sidebar() {

      $Menu = Console_Header::navigationdata();


      $final = '<div class="accordion" id="sidebar">';

      foreach($Menu as $floor => $packet){

        $final .= '<div class="accordion-group">';
        $final .= '<div class="accordion-heading">
                    <a class="accordion-toggle" data-toggle="collapse" data-parent="#sidebar" href="#collapse'.$floor.'">'.Str::upper($packet['header']).'</a>
                  </div>';
        $final .= '<div id="collapse'.$floor.'" class="accordion-body collapse">
                    <div class="accordion-inner">';
        if(!empty($packet['parent'])){
          $final .= '<ul class="nav nav-list">';
          foreach ($packet['parent'] as $key => $action){
            $final .= '<li><a href="#" onclick="setFiler('."'".url($action['path'])."','".$action['alias']."'".')"><i class="icon-play"></i>&nbsp;'.Str::title($action['alias']).'</a></li>';

            // array_push($navValue, array( , url($action['path']), false, false, null, 'play'));
          
          }        
          $final .= '</ul>';
          
        }
        $final .= '  </div>
                  </div>';
        $final .= '</div>';
      }

      $final .= '</div>';

    return $final;

  }

    /**
     * breadcrumb function
     * Create breadcrumb
     * @return string
     * @author joharijumali
     **/

  public static function breadcrumb(){

    $Menu = Admin_Menu::menuGenerator();

    $butternbread = array();

    foreach ($Menu as $floor => $packet){
      foreach ($packet->page->action as $key => $action){
         if($packet->packet == Str::lower(URI::segment(1)) && $packet->controller->name == Str::lower(URI::segment(2)) && $action->name == Str::lower(URI::segment(3)) || (URI::segment(3) == NULL && $action->name == $packet->controller->name && Str::lower(URI::segment(2)) == $packet->controller->name)){
            $butternbread[Str::upper($packet->controller->alias)] = '#' ;
            array_push($butternbread, Str::title($action->alias));
        }
      }
    }

    return Breadcrumb::create($butternbread);

  }

}



?>